home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Frameworks / MADE 1.0.1 / Essential Headers.h < prev    next >
Encoding:
Text File  |  1997-06-04  |  3.7 KB  |  109 lines  |  [TEXT/CWIE]

  1. // MADE - Macintosh Application Development Essentials
  2. // ---------------------------------------------------
  3.  
  4. // (c) Gideon Greenspan, Sig Software - June 1997 - http://www.kagi.com/gdg/
  5.  
  6. // These files can only be used for experimental standalone purposes. To obtain
  7. // fully commented code, and licenses for standalone, shareware, internal and
  8. // commercial usage, run the enclosed Register application.
  9.  
  10. // Essential Headers.h
  11. //
  12. // A header file containing all prototypes and global variables for the MADE package.
  13. //
  14. // Version 1.0.0 - 10th November 1996
  15.  
  16. #include "Essential Settings.h"
  17.  
  18. typedef OSErr Error;
  19.  
  20. void*    AllocPtr(Error* error, Size allocate);
  21.             // try to create non-movable memory block
  22. void**    AllocHandle(Error* error, Size allocate);
  23.             // try to create movable memory block
  24. void    DestroyPtr(void* pointer);
  25.             // destroy non-movable memory block
  26. void    DestroyHandle(void** handle);
  27.             // destroy movable memory block
  28.  
  29. #if Project_Under_Development
  30.  
  31.     void    HandleAssertFailure(char* file, char* date, int line); // params shown in dialog
  32.  
  33.     #define    Assert(test)    { if (!(test)) HandleAssertFailure(__FILE__, __DATE__, __LINE__); }
  34.                 // calls failure handler with necessary parameters if text fails
  35.                 // NOTE : If Pool Strings is off under CodeWarrior C/C++ this will cause
  36.                 // unnecessary code expansion because of all the file names and dates.
  37.     
  38.     // Whenever locking or unlocking handlers, use LockHandle and UnlockHandle, not the
  39.     // system calls HLock and HUnlock. This will let you use locking assertion later.
  40.     
  41. #else
  42.  
  43.     #define        Assert(test)    ;
  44.  
  45. #endif
  46.  
  47. #if Project_Under_Development && Assert_Memory_Locking
  48.  
  49.     void    LockHandleAssert(void** handle);
  50.     void    UnlockHandleAssert(void** handle);
  51.     
  52.     #define LockHandle(handle) LockHandleAssert(handle)        // checks status is changed
  53.     #define UnlockHandle(handle) UnlockHandleAssert(handle)    // checks status is changed
  54.  
  55. #else
  56.  
  57.     #define LockHandle(handle) HLock((Handle)(handle))        // calls normal Mac Toolbox
  58.     #define UnlockHandle(handle) HUnlock((Handle)(handle))    // calls normal Mac Toolbox
  59.     
  60. #endif
  61.  
  62. #define    AssertRange(test, minimum, maximum)    Assert((test>=minimum)&&(test<=maximum));
  63.             // Asserts test is within minimum and maximum values
  64.  
  65. void    TestError(Error error);
  66.             // displays relevant error dialog if error is non-zero
  67. Error    TestResError(void* resource);
  68.             // checks for zero resource handle, ResError, shows dialog and returns error code
  69. Error    TestMemError(void* pointer);
  70.             // checks for zero pointer, MemError, shows dialog and returns error code
  71.  
  72. // Useful miniature labels for catching error conditions five levels deep
  73.  
  74. #define _e            failed:;
  75. #define    _e2            failed2:;
  76. #define _e3            failed3:;
  77. #define _e4            failed4:;
  78. #define _e5            failed5:;
  79.  
  80. #define _g            goto failed;
  81. #define _g2            goto failed2;
  82. #define _g3            goto failed3;
  83. #define _g4            goto failed4;
  84. #define _g5            goto failed5;
  85.  
  86. #define    _i(param)    { if (param) _g }
  87. #define    _i2(param)    { if (param) _g2 }
  88. #define    _i3(param)    { if (param) _g3 }
  89. #define    _i4(param)    { if (param) _g4 }
  90. #define    _i5(param)    { if (param) _g5 }
  91.  
  92. extern Boolean        applicationHasQuit;        // set high to end event loop
  93. extern void*        dummy;                    // used for discarding unwanted results
  94. extern WindowPtr    frontWindow;            // which Window is in front of the rest
  95.  
  96. Boolean                CheckGestaltBit(OSType selector, char bit); // for determining environment
  97. void                ShowResCursor(short cursorID); // loads cursor from resource and displays
  98.  
  99. #if Use_Drag_Manager
  100.  
  101.     void    CreateDragRegion(RgnHandle region);
  102.                 // Turns the given region in local co-ordinates into a drag frame region in
  103.                 // global co-ordinates, using the current active GrafPort. This is very
  104.                 // useful for initialising drags with TrackDrag().
  105.  
  106. #endif
  107.  
  108. #define                System_Software_Version_Error    1996 // used when needed OS is missing
  109.